package com.sub.project.info.controller;

import com.sub.framework.web.controller.BaseController;
import com.sub.framework.web.domain.AjaxResult;
import com.sub.framework.web.page.TableDataInfo;
import com.sub.project.info.domain.Attribute;
import com.sub.project.info.domain.MtoPost;
import com.sub.project.info.service.BlogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/system/blog/" )
public class BlogController extends BaseController {

    @Autowired
    BlogService blogService;

    @GetMapping("list")
    public TableDataInfo getList(){
        startPage();
        List<MtoPost> blogList = blogService.list();
        return  getDataTable(blogList);
    }

    @GetMapping("{id}")
    public AjaxResult getId(@PathVariable("id" )Integer id){
        startPage();
        Attribute blog = blogService.findById(id);
          return AjaxResult.success(blog);
    }
}
